package com.example.parkingproject.controller;

import com.example.parkingproject.jopo.vo.BlackVo;
import com.example.parkingproject.result.JsonResult;
import com.example.parkingproject.service.BlackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/black")
@Slf4j
public class BlackController {

    @Autowired
    BlackService blackService;
    @RequestMapping("/getList")
    public JsonResult<List<BlackVo>> getList(){
        List<BlackVo> list =  blackService.getList();
        log.debug("返回黑名单{}",list);
        return JsonResult.ok(list);
    }

    @RequestMapping("/search")
    public JsonResult<List<BlackVo>> search(String carId){

        List<BlackVo> list  = blackService.search(carId);
        log.debug("传出的查询结果为{}",list);
        return JsonResult.ok(list);
    }

    @RequestMapping("/delete")
    public JsonResult delete(Integer id){
        log.debug("传入id为{}",id);
        blackService.delete(id);
        return JsonResult.ok();
    }
}
